let strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
var groupAnagrams = function(strs) {
    let map = new Map()
    for(let i=0;i<strs.length;i++){
        let key = strs[i].split('').sort().join('')
        let list =map.get(key)?map.get(key):new Array();
        list.push(strs[i])
        map.set(key,list)
    }
    console.log(map);
    return Array.from(map.values());
}
console.log(groupAnagrams(strs));


